﻿#ifndef __NGX_MEMORY_H__
#define __NGX_MEMORY_H__
#include <stddef.h>
class CMemory 
{
private:
    CMemory(){}
public:
    ~CMemory(){}
private:
    static CMemory *m_instance;
public:
    static CMemory* GetInstance()
    {
        if(m_instance == NULL)
        {
            if(m_instance == NULL)
            {
                /*第一次调用不应该放在线程中，
                应该放在主进程中，以免和其他
                线程调用冲突从而导致同时执行两次new CMemory*/
                m_instance = new CMemory();
                static CGarhuishou cl; 
            }
        }
        return m_instance;
    }
    class CGarhuishou 
    {
    public:
        ~CGarhuishou()
        {
            if(CMemory::m_instance)
            {
                //这个释放是整个系统退出的时候，系统来调用释放内存的哦
                delete CMemory::m_instance; 
                CMemory::m_instance = NULL; 
            }
        }
    };
public:
    void *AllocMemory(int memCount,bool ifmemset);
    void FreeMemory(void *point);
};

#endif
